import numpy as np
import os

"""
fromstring的参数

dtype=np.int64 >>> 加载后的数据以dtype为int64的格式放在array里
sep=',' >>> 加载数据时，将用都好把数据进行分割
"""
row_string = "20131, 10, 67, 20132, 11, 88, 20133, 12, 98, 20134, 8, 100, 20135, 9, 75, 20136, 12, 78"

data = np.fromstring(row_string, dtype=np.int64, sep=',')
data = data.reshape(6, 3)
# print(data)

np.save('files/save-data.npy', data)
# print(f'data file in directory: {os.listdir("files")}')
npy_data = np.load('files/save-data.npy')
# print(npy_data)

train_data = np.array([1, 2, 3])
test_data = np.array([11, 22, 33])

np.savez('files/save-data.npz', train=train_data, test=test_data)

# 加载npz
npz_data = np.load('files/save-data.npz')
print(f'train data: {npz_data["train"]}')
print(f'test data: {npz_data["test"]}')




